﻿<UserControl x:Class="LatestChatty.Controls.MessageListControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:chatty="clr-namespace:LatestChatty.Classes"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="#FFFFFF"
    d:DesignHeight="480" d:DesignWidth="480">

    <UserControl.Resources>
        <chatty:UnreadConverter x:Name="UnreadConverter"/>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <ListBox Margin="0,0,0,0" ItemsSource="{Binding Messages}" SelectionChanged="SelectionChanged">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="0,0,0,10" Width="455">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid Margin="0,0,0,0" Background="{Binding unread, Converter={StaticResource UnreadConverter}}">
                            <TextBlock HorizontalAlignment="Left" Text="{Binding from}" FontSize="20" Foreground="#ffba00"/>
                            <TextBlock HorizontalAlignment="Right" Text="{Binding dateText}" FontSize="20" Foreground="#888888"/>
                        </Grid>
                        <TextBlock Grid.Row="1" Text="{Binding subject}" TextWrapping="NoWrap" Style="{StaticResource PhoneTextNormalStyle}" Foreground="#FFFFFF"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
